package com.hugo.maomi_first.zhuanti.adapter;

import android.content.Context;
import android.support.v7.widget.RecyclerView;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ImageView;

import com.hugo.maomi_first.R;
import com.hugo.maomi_first.bean.ZhuanTiHeaderBean;
import com.hugo.maomi_first.utils.ImageLoader;

import java.util.List;

import butterknife.Bind;
import butterknife.ButterKnife;

/**
 * Created by Administrator on 2016/7/5.
 */
public class RecyclerAdapter extends RecyclerView.Adapter<RecyclerView.ViewHolder> {
    private Context context = null;
    private List<ZhuanTiHeaderBean.DataBean.ItemsBean> list = null;
    private LayoutInflater mInflater = null;

    public RecyclerAdapter(Context context, List<ZhuanTiHeaderBean.DataBean.ItemsBean> list) {
        this.context = context;
        this.list = list;
        mInflater = (LayoutInflater) context.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
    }

    @Override
    public RecyclerView.ViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
        View view = mInflater.inflate(R.layout.item_recyclerview_header, parent, false);
        return new ViewHolder(view);
    }

    @Override
    public void onBindViewHolder(RecyclerView.ViewHolder holder, int position) {
        if (holder instanceof ViewHolder) {
            ViewHolder viewHolder1= (ViewHolder) holder;
            ImageLoader.getInstance().displayImage(context,list.get(position).getImg().getImg_url(),viewHolder1.imageViewZhuangtiHeader);
        }
    }

    @Override
    public int getItemCount() {
        return list.size();
    }


    static class ViewHolder extends RecyclerView.ViewHolder {
        @Bind(R.id.imageView_zhuangti_header)
        ImageView imageViewZhuangtiHeader;

        ViewHolder(View view) {
            super(view);
            ButterKnife.bind(this, view);
        }
    }
}